<html>
<head><meta charset="utf-8"><title>DefId for a given symbol · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/DefId.20for.20a.20given.20symbol.html">DefId for a given symbol</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228499283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/DefId%20for%20a%20given%20symbol/near/228499283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael Coblenz <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/DefId.20for.20a.20given.20symbol.html#228499283">(Mar 02 2021 at 22:34)</a>:</h4>
<p>I have an (experimental) feature that involves a builtin symbol. The symbol is defined in a crate that I'm providing, but the compiler needs to be able to use it in certain special cases. Is there a way to look up the DefId given the symbol name?</p>



<a name="228499327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/DefId%20for%20a%20given%20symbol/near/228499327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael Coblenz <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/DefId.20for.20a.20given.20symbol.html#228499327">(Mar 02 2021 at 22:35)</a>:</h4>
<p>(context: I'm working on a garbage collector, and tracing requires some special compiler support, so I have a special trait that corresponds to being traceable)</p>



<a name="228524385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/DefId%20for%20a%20given%20symbol/near/228524385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/DefId.20for.20a.20given.20symbol.html#228524385">(Mar 03 2021 at 02:28)</a>:</h4>
<p>You can annotate it with <code>rustc_diagnostic_item</code> I think</p>



<a name="228531492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/DefId%20for%20a%20given%20symbol/near/228531492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Michael Coblenz <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/DefId.20for.20a.20given.20symbol.html#228531492">(Mar 03 2021 at 03:58)</a>:</h4>
<p>I don't think that works — I need to be able to get the DefId "out of thin air" rather than in the context of a specific crate.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>